package com.wjh.garbagetype.bean;

import com.wjh.garbagetype.constant.Url;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

/**
 * @Description bean
 * @Date 2020/4/18 14:44
 * @Created by jiahui.wu
 */
@Configuration
public class Beans {

    @Bean
    public RestTemplate getRestTemplate(){
        //复杂构造函数的使用
        SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
        // 设置超时
        requestFactory.setConnectTimeout(Url.TIME_OUT);
        requestFactory.setReadTimeout(Url.TIME_OUT);
        return new RestTemplate(requestFactory);
    }

}
